package com.rykj.energy.task.manage.schedule;

import com.alibaba.fastjson.JSONObject;
import com.rykj.energy.database.pojo.vo.CaptureParamVo;
import com.rykj.energy.task.capture.service.ICaptureService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

@Slf4j
public class ManualCaptureJob extends QuartzJobBean {

    @Autowired
    private ICaptureService captureService;

    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {

        JobDataMap jobDataMap = context.getMergedJobDataMap();
        log.info("==执行抓图任务中===========>"+ JSONObject.toJSONString(jobDataMap));
        CaptureParamVo captureParamVo = new CaptureParamVo();
        captureParamVo.setCameraId(jobDataMap.getIntValue("cameraId"));
        captureParamVo.setTaskId(jobDataMap.getIntValue("taskId"));
        captureParamVo.setTaskCode(jobDataMap.getString("taskCode"));
        captureParamVo.setPresetId(jobDataMap.get("presetId")!=null?jobDataMap.getIntValue("presetId"):null);
        captureParamVo.setTaskType(jobDataMap.getString("taskType"));
        captureService.exeCapturePlan(captureParamVo);

    }
}
